import IPython
def configure_plotly_browser_state():
display(IPython.core.display.HTML('''
<script src="/static/components/requirejs/require.js"></script>
<script>
requirejs.config({
paths: {
base: '/static/base',
plotly: 'https://cdn.plot.ly/plotly-1.5.1.min.js?noext',
},
});
</script>
'''))
IPython.get_ipython().events.register('pre_run_cell', configure_plotly_browser_state)
#Bibliotecas de análise de dados
import pandas as pd
import numpy as np
# Bibliotecas gráficas
import plotly.express as px
import plotly.graph_objects as go
import plotly.figure_factory as ff
from plotly.subplots import make_subplots
from matplotlib import pyplot as plt
#Configurações de output do Notebook
pd.set_option('display.float_format', lambda x: '%.3f' % x)
pd.set_option('display.max_columns', None)
from IPython.core.display import HTML as Center
Center(""" <style>
.output_png {
display: table-cell;
text-align: center;
vertical-align: middle;
}
</style> """)
#Configurações de exportação de gráficos
import chart_studio
import chart_studio.plotly as py
import chart_studio.tools as tls
username = "theweckerle"
api_key = "liegKf44ZIsiHYKJ9nrH"
chart_studio.tools.set_credentials_file(username=username, api_key=api_key)
data = pd.read_csv(r'C:\Users\joaow.000\Downloads\PSCompPars_2022.06.03_09.36.48.csv')
data
| loc_rowid | pl_name | hostname | sy_snum | sy_pnum | sy_mnum | discoverymethod | disc_year | disc_facility | pl_orbper | pl_orbpererr1 | pl_orbpererr2 | pl_orbperlim | pl_orbsmax | pl_orbsmaxerr1 | pl_orbsmaxerr2 | pl_orbsmaxlim | pl_rade | pl_radeerr1 | pl_radeerr2 | pl_radelim | pl_radj | pl_radjerr1 | pl_radjerr2 | pl_radjlim | pl_bmasse | pl_bmasseerr1 | pl_bmasseerr2 | pl_bmasselim | pl_bmassj | pl_bmassjerr1 | pl_bmassjerr2 | pl_bmassjlim | pl_bmassprov | pl_dens | pl_denserr1 | pl_denserr2 | pl_denslim | pl_orbeccen | pl_orbeccenerr1 | pl_orbeccenerr2 | pl_orbeccenlim | pl_insol | pl_insolerr1 | pl_insolerr2 | pl_insollim | pl_eqt | pl_eqterr1 | pl_eqterr2 | pl_eqtlim | ttv_flag | pl_ratdor | pl_ratdorerr1 | pl_ratdorerr2 | pl_ratdorlim | pl_ratror | pl_ratrorerr1 | pl_ratrorerr2 | pl_ratrorlim | st_spectype | st_teff | st_tefferr1 | st_tefferr2 | st_tefflim | st_rad | st_raderr1 | st_raderr2 | st_radlim | st_mass | st_masserr1 | st_masserr2 | st_masslim | st_met | st_meterr1 | st_meterr2 | st_metlim | st_metratio | st_lum | st_lumerr1 | st_lumerr2 | st_lumlim | st_logg | st_loggerr1 | st_loggerr2 | st_logglim | st_age | st_ageerr1 | st_ageerr2 | st_agelim | sy_dist | sy_disterr1 | sy_disterr2 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 1 | 11 Com b | 11 Com | 2 | 1 | 0 | Radial Velocity | 2007 | Xinglong Station | 326.030 | 0.320 | -0.320 | 0.000 | 1.290 | 0.050 | -0.050 | 0.000 | 12.100 | NaN | NaN | 0.000 | 1.080 | NaN | NaN | 0.000 | 6165.600 | 476.700 | -476.700 | 0.000 | 19.400 | 1.500 | -1.500 | 0.000 | Msini | 19.100 | NaN | NaN | 0.000 | 0.231 | 0.005 | -0.005 | 0.000 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 0 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | G8 III | 4742.000 | 100.000 | -100.000 | 0.000 | 19.000 | 2.000 | -2.000 | 0.000 | 2.700 | 0.300 | -0.300 | 0.000 | -0.350 | 0.090 | -0.090 | 0.000 | [Fe/H] | 2.243 | 0.071 | -0.085 | 0.000 | 2.310 | 0.100 | -0.100 | 0.000 | NaN | NaN | NaN | NaN | 93.185 | 1.924 | -1.924 |
| 1 | 2 | 11 UMi b | 11 UMi | 1 | 1 | 0 | Radial Velocity | 2009 | Thueringer Landessternwarte Tautenburg | 516.220 | 3.200 | -3.200 | 0.000 | 1.530 | 0.070 | -0.070 | 0.000 | 12.300 | NaN | NaN | 0.000 | 1.090 | NaN | NaN | 0.000 | 4684.814 | 794.575 | -794.575 | 0.000 | 14.740 | 2.500 | -2.500 | 0.000 | Msini | 13.800 | NaN | NaN | 0.000 | 0.080 | 0.030 | -0.030 | 0.000 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 0 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | K4 III | 4213.000 | 46.000 | -46.000 | 0.000 | 29.790 | 2.840 | -2.840 | 0.000 | 2.780 | 0.690 | -0.690 | 0.000 | -0.020 | NaN | NaN | 0.000 | [Fe/H] | 2.430 | 0.008 | -0.008 | 0.000 | 1.930 | 0.070 | -0.070 | 0.000 | 1.560 | 0.540 | -0.540 | 0.000 | 125.321 | 1.976 | -1.976 |
| 2 | 3 | 14 And b | 14 And | 1 | 1 | 0 | Radial Velocity | 2008 | Okayama Astrophysical Observatory | 185.840 | 0.230 | -0.230 | 0.000 | 0.830 | NaN | NaN | 0.000 | 12.900 | NaN | NaN | 0.000 | 1.150 | NaN | NaN | 0.000 | 1525.500 | NaN | NaN | 0.000 | 4.800 | NaN | NaN | 0.000 | Msini | 3.900 | NaN | NaN | 0.000 | 0.000 | NaN | NaN | 0.000 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 0 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | K0 III | 4813.000 | 20.000 | -20.000 | 0.000 | 11.000 | 1.000 | -1.000 | 0.000 | 2.200 | 0.100 | -0.200 | 0.000 | -0.240 | 0.030 | -0.030 | 0.000 | [Fe/H] | 1.763 | NaN | NaN | 0.000 | 2.630 | 0.070 | -0.070 | 0.000 | 4.500 | 1.900 | -1.900 | 0.000 | 75.439 | 0.714 | -0.714 |
| 3 | 4 | 14 Her b | 14 Her | 1 | 2 | 0 | Radial Velocity | 2002 | W. M. Keck Observatory | 1773.400 | 2.500 | -2.500 | 0.000 | 2.930 | 0.080 | -0.080 | 0.000 | 12.900 | NaN | NaN | 0.000 | 1.150 | NaN | NaN | 0.000 | 1481.088 | 47.675 | -47.675 | 0.000 | 4.660 | 0.150 | -0.150 | 0.000 | Msini | 3.790 | NaN | NaN | 0.000 | 0.370 | 0.000 | 0.000 | 0.000 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 0 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | K0 V | 5338.000 | 25.000 | -25.000 | 0.000 | 0.930 | 0.010 | -0.010 | 0.000 | 0.900 | 0.040 | -0.040 | 0.000 | 0.410 | NaN | NaN | 0.000 | [Fe/H] | -0.153 | 0.012 | -0.010 | 0.000 | 4.450 | 0.020 | -0.020 | 0.000 | 3.900 | NaN | NaN | 0.000 | 17.932 | 0.007 | -0.007 |
| 4 | 5 | 16 Cyg B b | 16 Cyg B | 3 | 1 | 0 | Radial Velocity | 1996 | Multiple Observatories | 798.500 | 1.000 | -1.000 | 0.000 | 1.660 | 0.030 | -0.030 | 0.000 | 13.500 | NaN | NaN | 0.000 | 1.200 | NaN | NaN | 0.000 | 565.737 | 25.426 | -25.426 | 0.000 | 1.780 | 0.080 | -0.080 | 0.000 | Msini | 1.260 | NaN | NaN | 0.000 | 0.680 | 0.020 | -0.020 | 0.000 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 0 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | G3 V | 5750.000 | 8.000 | -8.000 | 0.000 | 1.130 | 0.010 | -0.010 | 0.000 | 1.080 | 0.040 | -0.040 | 0.000 | 0.060 | NaN | NaN | 0.000 | [Fe/H] | 0.097 | 0.009 | -0.013 | 0.000 | 4.360 | 0.010 | -0.010 | 0.000 | 7.400 | 0.100 | -0.100 | 0.000 | 21.140 | 0.011 | -0.011 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 5030 | 5031 | ups And b | ups And | 2 | 3 | 0 | Radial Velocity | 1996 | Lick Observatory | 4.617 | 0.000 | -0.000 | 0.000 | 0.059 | 0.000 | 0.000 | 0.000 | 14.000 | NaN | NaN | 0.000 | 1.250 | NaN | NaN | 0.000 | 218.531 | 1.398 | -1.398 | 0.000 | 0.688 | 0.004 | -0.004 | 0.000 | Msini | 0.438 | NaN | NaN | 0.000 | 0.021 | 0.001 | -0.001 | 0.000 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 0 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | F8 V | 6156.770 | 112.160 | -112.160 | 0.000 | 1.560 | NaN | NaN | 0.000 | 1.300 | NaN | NaN | 0.000 | 0.101 | 0.010 | -0.010 | 0.000 | [M/H] | 0.525 | 0.013 | -0.018 | 0.000 | 4.130 | 0.020 | -0.020 | 0.000 | 5.000 | NaN | NaN | 0.000 | 13.405 | 0.064 | -0.063 |
| 5031 | 5032 | ups And c | ups And | 2 | 3 | 0 | Radial Velocity | 1999 | Multiple Observatories | 241.258 | 0.064 | -0.064 | 0.000 | 0.828 | 0.000 | -0.000 | 0.000 | 12.300 | NaN | NaN | 0.000 | 1.100 | NaN | NaN | 0.000 | 4443.241 | 731.005 | -1684.491 | 0.000 | 13.980 | 2.300 | -5.300 | 0.000 | Mass | 13.100 | NaN | NaN | 0.000 | 0.260 | 0.008 | -0.008 | 0.000 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 0 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | F8 V | 6156.770 | 112.160 | -112.160 | 0.000 | 1.560 | NaN | NaN | 0.000 | 1.300 | NaN | NaN | 0.000 | 0.101 | 0.010 | -0.010 | 0.000 | [M/H] | 0.525 | 0.013 | -0.018 | 0.000 | 4.130 | 0.020 | -0.020 | 0.000 | 5.000 | NaN | NaN | 0.000 | 13.405 | 0.064 | -0.063 |
| 5032 | 5033 | ups And d | ups And | 2 | 3 | 0 | Radial Velocity | 1999 | Multiple Observatories | 1276.460 | 0.570 | -0.570 | 0.000 | 2.513 | 0.001 | -0.001 | 0.000 | 12.500 | NaN | NaN | 0.000 | 1.110 | NaN | NaN | 0.000 | 3257.741 | 222.480 | -1048.834 | 0.000 | 10.250 | 0.700 | -3.300 | 0.000 | Mass | 9.170 | NaN | NaN | 0.000 | 0.299 | 0.007 | -0.007 | 0.000 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 0 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | F8 V | 6156.770 | 112.160 | -112.160 | 0.000 | 1.560 | NaN | NaN | 0.000 | 1.300 | NaN | NaN | 0.000 | 0.101 | 0.010 | -0.010 | 0.000 | [M/H] | 0.525 | 0.013 | -0.018 | 0.000 | 4.130 | 0.020 | -0.020 | 0.000 | 5.000 | NaN | NaN | 0.000 | 13.405 | 0.064 | -0.063 |
| 5033 | 5034 | ups Leo b | ups Leo | 1 | 1 | 0 | Radial Velocity | 2021 | Okayama Astrophysical Observatory | 385.200 | 2.800 | -1.300 | 0.000 | 1.180 | 0.110 | -0.320 | 0.000 | 14.200 | NaN | NaN | 0.000 | 1.270 | NaN | NaN | 0.000 | 162.092 | 19.070 | -82.635 | 0.000 | 0.510 | 0.060 | -0.260 | 0.000 | Msini | 0.311 | NaN | NaN | 0.000 | 0.320 | 0.134 | -0.218 | 0.000 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 0 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | G9 III | 4836.000 | NaN | NaN | 0.000 | 11.220 | 3.150 | -0.450 | 0.000 | 1.480 | 0.900 | -0.380 | 0.000 | -0.200 | 0.090 | -0.080 | 0.000 | [Fe/H] | 1.800 | 0.221 | -0.055 | 0.000 | 2.460 | 0.090 | -0.090 | 0.000 | NaN | NaN | NaN | NaN | 52.597 | 0.927 | -0.896 |
| 5034 | 5035 | xi Aql b | xi Aql | 1 | 1 | 0 | Radial Velocity | 2007 | Okayama Astrophysical Observatory | 136.750 | 0.250 | -0.250 | 0.000 | 0.680 | NaN | NaN | 0.000 | 13.200 | NaN | NaN | 0.000 | 1.180 | NaN | NaN | 0.000 | 890.000 | NaN | NaN | 0.000 | 2.800 | NaN | NaN | 0.000 | Msini | 2.130 | NaN | NaN | 0.000 | 0.000 | NaN | NaN | 0.000 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 0 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | G9 III | 4780.000 | 30.000 | -30.000 | 0.000 | 12.000 | NaN | NaN | 0.000 | 2.200 | NaN | NaN | 0.000 | -0.205 | 0.039 | -0.039 | 0.000 | [Fe/H] | 1.839 | NaN | NaN | 0.000 | 2.660 | 0.110 | -0.110 | 0.000 | 7.100 | 3.600 | -3.600 | 0.000 | 56.186 | 0.560 | -0.560 |
5035 rows × 92 columns
fig = go.Figure(data=[go.Table(
header=dict(values=list(['Planet Name', 'Host Name', 'Discovery Method', 'Discovery Facility',
'Discovery Year', 'Orbital Period [days]', ' Planet Radius [Earth Radius]',
'Stellar Mass [Solar mass]','Planet Radius [Jupiter Radius]'], ),
fill_color='paleturquoise',
align='left'),
cells=dict(values=[data.pl_name, data.hostname, data.discoverymethod,
data.disc_facility, data.disc_year, data.pl_orbper, data.pl_rade, data.st_mass, data.pl_radj],
fill_color='lavender',
align='left'))
])
fig.show()
fig = px.histogram(x=data['disc_year'])
fig.show()
fig = px.pie(names=data['disc_facility'])
fig.update_traces(textposition='inside', textinfo='percent+label')
fig.show()




fig = px.histogram(x=data['discoverymethod'] )
fig.show()
figg = make_subplots(
rows=1, cols=2,
#subplot_titles=("Title 1", "Title 2"),
shared_xaxes=False,
vertical_spacing =0.01,)# tune this value until the two charts don't overlap
figg.add_trace(go.Histogram(x=data["sy_snum"],name="Number of Stars", )
,row=1, col=1)
figg.add_trace(go.Histogram(x=data["sy_pnum"],name="Number of Planets"),row=1, col=2)
figg.update_xaxes(title_text="Number of Stars", row=1, col=1, )
figg.update_xaxes(title_text="Number of Planets", row=1, col=2, )
figg.update_yaxes(title_text="Counts", row=1, col=1, )
figg.show()
fig=px.histogram(x=data['pl_bmasse'], nbins = 200)
fig.update_xaxes(title_text="Planet Mass in terms of Earth Mass" )
fig.add_vline(x=np.mean(data['pl_bmasse']), line_width=2, line_color="red")
fig.add_annotation(x=215,y=2500,
text='Mean Value = ' + str(round(np.mean(data['pl_bmasse']),2)) + ' Earth Mass' ,
ax=110, showarrow=True)
fig.show()
fig=px.box(y=data['pl_bmassj'], color=data['pl_bmassprov'])
fig.update_xaxes(title_text="Planet Mass in terms of Jupiter Mass" )
fig.show()
data = data.drop(data[data['pl_bmassj'] > 13 ].index)
print(np.mean(data['pl_bmasse']))
223.0246095817252
fig=px.histogram(x=data['pl_radj'])
fig.update_xaxes(title_text="Planet Radii in terms of Jupiter Radii" )
fig.add_vline(x=0.0892147, line_width=2, line_color="black")
fig.add_annotation(x=0.08,y=700, text='Earth Radii', ax=54, showarrow=True)
fig.add_vline(x=np.mean(data['pl_radj']), line_width=2, line_color="red")
fig.add_annotation(x=0.48,y=400,
text='Mean Value = ' + str(round(np.mean(data['pl_radj']),2)) + ' Jupiter Radii' ,
ax=110, showarrow=True)
fig.show()
data7 = data.drop(data[data['pl_orbper'] > 2000 ].index)
fig=px.histogram(x=data7['pl_orbper'])
fig.update_xaxes(title_text="Orbital Period [days]" )
fig.show()
data1 = data.drop(data[data['pl_orbsmax'] > 6 ].index)
fig = px.scatter(x=data1['pl_orbsmax']**3, y = data1['pl_orbper']**2, trendline='ols',
color=data1['discoverymethod'], trendline_scope='overall')
fig.update_xaxes(title_text="Orbit Semi-Major Axis [au]", range = [0.001, 100] )
fig.update_yaxes(title_text="Orbital Period [days]", range=[0,10000000])
fig.show()